================================================================================
                                样例使用说明
                                Sample Description
================================================================================
功能描述:
此样例是利用轮询对串口外设接口（SPI）与外部设备以全双工串行方式进行通信的演示，
主设备提供通信时钟SCK，通过MOSI/MISO引脚发送/接收数据。从设备通过MOSI/MISO引脚接
收/发送数据。数据以主机提供的SCK沿同步被移位，完成全双工通信。

Function descriptions:
This sample is a demonstration of using polling to communicate with a serial 
peripheral interface (SPI) and an external device in full-duplex serial mode. 
The master device provides the communication clock SCK and sends/receives data 
through the MOSI/MISO pin. The slave device receives/transmits data through the 
MOSI/MISO pins. The data is shifted synchronously along the SCK provided by the 
master to complete full-duplex communication.
================================================================================
测试环境：
测试用板：PY32MD550_STK
MDK版本： 5.28

Test environment:
Test board: PY32MD550_STK
MDK Version: 5.28
================================================================================
使用步骤:
1.准备两块STK板，一块作为主机，一块作为从机。
2.打开"#define BOARD_IN_MASTER_MODE"宏定义，编译程序下载到主机。
3.屏蔽"#define BOARD_IN_MASTER_MODE"宏定义，编译程序下载到从机。
4.主机与从机引脚连接(箭头指向为信号传输方向) 
主机MASTER：         从机SLAVE：
NSS(PA4)   ----->    NSS(PA4)
SCK(PA5)   ----->    SCK(PA5)
MISO(PA6)  <-----    MISO(PA6)
MOSI(PA7)  ----->    MOSI(PA7)
5.主从机上电
6.按下从机复位按键先运行从机程序，再按下主机用户按键运行主机程序
7.观察主从机的LED灯，当主机和从机LED灯由常暗转为常亮状态，则表明主机、从机收发数
据成功；当主机或从机LED灯处于闪烁状态，则表明主机、从机收发数据失败。

Example execution steps:
1. Prepare two STK boards, one as the host and the other as the slave
2. Open the “#define BOARD_IN_MASTER_MODE” macro definition, compile the program 
to download to the host.
3. Mask “#define BOARD_IN_MASTER_MODE” macro definition, compile the program to 
download to the slave.
4. The host is connected to the SLAVE pin (the arrow points in the signal 
transmission direction).
MASTER：             SLAVE：
NSS(PA4)   ----->    NSS(PA4)
SCK(PA5)   ----->    SCK(PA5)
MISO(PA6)  <-----    MISO(PA6)
MOSI(PA7)  ----->    MOSI(PA7)
5. Power on the host and slave
6. Press the slave reset button to run the slave program first, and then press 
the host user button to run the host program
7. Observe the LED lights of the master and slave. When the LED lights of the 
master and slave turn from normal dark to steady on, it indicates that the 
master and slave receive and send data successfully; When the LED of the host or 
slave is blinking, it indicates that the host or slave fails to receive and send 
data.
================================================================================
注意事项:
1.必须先按从机复位按键使从机程序先运行，再按主机用户按键开始运行主机程序，否则会
导致主从机通信失败。
2.主机模式可通过程序设置IO控制方式为DMA方式、中断方式和查询方式。
3.NSS引脚只需要在使用NSS硬件方式时连接（本样例使用的是NSS硬件方式）。
4.开发板焊接了FLASH器件，使用该样例建议去除R42/R44/R45/R46/R47四个电阻。没有焊接
FLASH器件，无需关注这四个电阻。

Note:
1. You must press the slave reset button to make the slave program run first, 
and then press the host user button to start running the host program, 
otherwise, the communication between the host and slave will be fail.
2. The host mode can be programmed to set the IO control mode to DMA mode, 
interrupt mode and query mode.
3.NSS pins need to be connected only when using NSS hardware mode (this example 
uses NSS hardware mode).
4.The development board is soldered FLASH devices, the use of this sample is
recommended to remove the four resistors R42/R44/R45/R46/R47. No FLASH device is
soldered, no need to pay attention to these four resistors.
================================================================================
